package io.renren.modules.echarts.controller;


import io.renren.common.utils.R;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping("/test")
public class testController {

    @RequestMapping("/test1.jsonp")
    @ResponseBody
    public void getstudentAttendence(HttpServletRequest req, HttpServletResponse rps) throws JSONException {

        System.out.println("111111111111111111111");
        String str  = "Hello world";
        JSONObject json = new JSONObject();
        json.put("name", str);
        try {
            //前台定义的jsonp:'callback'
            rps.getWriter().print("successCallback("+json+")");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    @RequestMapping("/test2")
    public R getstudentAttendence1(@RequestParam Map<String, Object> params) {

        return R.ok().put("option","我来自2");
    }
}
